import React, { Component } from "react";
export default class App extends Component {
  //创建真实 DOM 容器
  user = React.createRef();
  pass = React.createRef();
  
  render() {
    return (
      <div>
        <h2>登录</h2>
        <hr />
        用户名: <input type="text" ref={this.user} /><br />
        密码: <input type="password" ref={this.pass} /><br />
        <hr />
        <button onClick={this.login}>登录</button>
      </div>
    );
  }

  //登录的方法
  login = () => {
    //获取输入的内容
    let username = this.user.current.value;
    let password = this.pass.current.value;
    //输出内容
    console.log(`当前用户的用户名为: ${username}, 密码为: ${password}`)
  }
  
}


